package com.softoa.contorller;

import com.softoa.pojo.Permission;
import com.softoa.pojo.Session;
import com.softoa.pojo.User;
import com.softoa.service.IPermisssionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

/**
 * @author LinKun
 * @date 2022-6-23 22:12
 */

@RestController
@RequestMapping("/permission")
@CrossOrigin
public class PermissionController {
    @Autowired
    IPermisssionService permisssionService;

    @RequestMapping("/show")
    java.util.List<Permission> showList(){return permisssionService.permissionList();
    }

    @RequestMapping("getpermission")
    java.util.List<Permission> getPermission(Session session){
        String s=session.getBothSidesId();
        System.out.println(s);
        java.util.List<Permission> permissions=new ArrayList<>();
        if(s.equals("系统管理员")){
            permissions = permisssionService.userPermissionSelect(3);
        }else if(s.endsWith("经理")){
            permissions = permisssionService.userPermissionSelect(2);
        }else{
            permissions = permisssionService.userPermissionSelect(1);
        }
        return permissions;
    }
}
